/*
 * random test for adventurer card
 * cs362 hw4
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <stdlib.h>
#include <time.h>

int main() {
    int n,p;
	int check;
	int seed = 0;
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;

    printf ("TESTING adventurer card cardEffect():\n");

    int card = adventurer;
    int choice1 = 0; //doesn't affect card
    int choice2 = 0; //doesn't affect card
    int choice3 = 0; //doesn't affect card
    int handPos = 0; //position of card in hand array, only testing one card
    int bonus = 0;
    int numTest = 2000;
    int preHandCount = 0;
    srand(time(NULL));

    for (n = 0; n < numTest; n++) {
    	// game input randomization
		seed = rand() % 1000+1;
		numPlayer = rand() % 3; numPlayer = numPlayer+2;
		memset(&G, 23, sizeof(struct gameState));
		initializeGame(numPlayer, k, seed, &G);
		// card input randomization
		p = rand() % numPlayer;
		G.whoseTurn = p;

		G.deckCount[p] = rand() % 11;
		G.discardCount[p] = rand() % MAX_DECK;
		preHandCount  = rand() % MAX_HAND;
		G.handCount[p] = preHandCount;

		//play card
		check = cardEffect(card, choice1, choice2, choice3, &G, handPos, &bonus);

		//assert results
		assert(check == 0);
    }

    printf("All tests passed!\n");

    return 0;
}
